package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

//攻略详情文章
@Getter@ToString@Setter
public class StrategyDetail extends BaseDomain{

    public static final Integer STATE_DISABLE =-1;//禁用
    public static final Integer STATE_SAVE=0;//草稿
    public static final Integer STATE_RELEASE =1;//发布

    private String title;

    private Date createTime;

    private Date releaseTime;

    private Integer sequence;

    private StrategyCatalog catalog;

    private String coverUrl;

    private Integer state=STATE_SAVE;

    private StrategyContent strategyContent;


    public String getStateName(){

        String stateNmae="草稿";
        if (STATE_DISABLE.equals(state)){
            stateNmae="禁用";
        }else if (STATE_RELEASE.equals(state)){
            stateNmae="发布";
        }
        return stateNmae;
    }

    public Object getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("createTime",createTime);
        map.put("releaseTime",releaseTime);
        map.put("sequence",sequence);
        map.put("catalog",catalog);
        map.put("sequence",sequence);
        map.put("catalog",catalog);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        if (strategyContent != null) {
            map.put("strategyContent",strategyContent.getContent());
        }

        return JSONUtil.toJSONString(map);
    }

}